package com.ychen.ruijee.common;

/**
 * 编写 ThreadLocal 封装工具类 用户保存和获取当前登录用户 id
 * @author ychen@gotop.cn
 * @date 2024-05-30 23:56
 */
public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    // 设置 ThreadLocal 中的值
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    // 获取 threadlocal 中的值
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
